//
//  BaseNetworkUtil.h
//  MapArgiculture
//
//  Created by xiongguobing on 2018/5/29.
//  Copyright © 2018年 xiongguobing. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface BaseModel : NSObject

@property (nonatomic, assign) NSInteger code;
@property (nonatomic, strong) NSString * message;


@end

//网络请求成功的标志位
static NSInteger networkSuccessStatus = 200;

typedef void(^success)(id response);
typedef void(^failure)(NSError * error);
typedef void(^downloadSuccess)(id response);

@interface BaseNetworkUtil : NSObject

/**< VPN是否在连接 */
@property (nonatomic, assign) BOOL isVPNConnected;


/**
 创建网络请求工具类的单例
 */
+ (instancetype)sharedInstance;


/**
 * GET请求
 * urlString模块的URL   方法里会拼上域名BaseURL
 */
- (void)getWithModuleURLStr:(NSString *)urlString
                 parameters:(NSDictionary *)parameters
                    success:(success)success
                    failure:(failure)failure
                    withHud:(BOOL)hud;

/**
 * POST请求
 * urlString模块的URL   方法里会拼上域名BaseURL
 */
- (void)postWithModuleURLStr:(NSString *)urlString
                  parameters:(NSDictionary *)parameters
                     success:(success)success
                     failure:(failure)failure
                     withHud:(BOOL)hud;

/**
 * 创建请求方法
 * urlString 需要传完整的URL
 * method：GET||POST
 * isBody: 是否是以raw的形式传入参数
 */
- (void)requestWithURLString:(NSString *)URLString
                  parameters:(NSDictionary *)parameters
                      method:(NSString *)method
                     success:(success)success
                     failure:(failure)failure
                      isBody:(BOOL)isBody;

/**
 * 创建请求方法
 * urlString 需要传完整的URL
 * method：GET||POST
 * isBody: 是否是以raw的形式传入参数
 * isHud: 是否显示hud
 */
- (void)requestWithURLString: (NSString *)URLString
                  parameters: (NSDictionary *)parameters
                      method: (NSString *)method
                     success:(success)success
                     failure:(failure)failure
                      isBody:(BOOL)isBody
                       isHud:(BOOL)isHud;


/**
 post请求

 @param urlString url
 @param parameters 参数
 @param success 成功回调
 @param failure 失败回调
 @param isShowError 是否显示错误信息
 */
- (void)postWithModuleURLStr:(NSString *)urlString
                  parameters:(NSDictionary *)parameters
                     success:(success)success
                     failure:(failure)failure
                 isShowError:(BOOL)isShowError;

/**
 下载方法

 @param url 下载链接
 @param path 存储的路径
 @param success 下载成功回调
 @param failure 失败回调
 */
- (void)downloadWithUrl:(NSString *)url path:(NSString *)path downloadSuccess:(downloadSuccess)success  failure:(failure)failure;


/**
 获取网络状态

 @return 蜂窝数据、WiFi、unknown
 */
+ (NSString *)getNetworkType;

@end
